#include <stdio.h>
#include <string.h>
#include <math.h>


char s[5][100];
double totc, totfat;
double weight[5];
double percent[5];
double c[5];
void count()
{
	int i, len, j;
	for (i=0; i<5; ++i) 
		weight[i] = percent[i] = c[i] = 0;

	for (i=0; i<5; ++i)
	{
		len = strlen(s[i]);
		if (s[i][len-1]=='g')
		{
			s[i][len-1] = 0;
			sscanf(s[i], "%lf", &weight[i]);
		}
		else if (s[i][len-1]=='%')
		{
			s[i][len-1] = 0;
//			percent[i] = atof(s[i]);
			sscanf(s[i], "%lf", &percent[i]);
		}
		else if (s[i][len-1]=='C' || s[i][len-1]=='c')
		{
			s[i][len-1] = 0;
			//c[i] = atof(s[i]);
            sscanf(s[i], "%lf", &c[i]);
		}
	}
	c[0] += weight[0] * 9;
	c[1] += weight[1] * 4;
	c[2] += weight[2] * 4;
	c[3] += weight[3] * 4;
	c[4] += weight[4] * 7;

	double totper=0, totka=0, tot;
	for (i=0; i<5; ++i)
	{
		totper += percent[i];		
		totka += c[i];
	}
	totper = 100 - totper;
	tot = totka / totper;
	for (i=0; i<5; ++i)
	{
		if (percent[i]>1e-5)
			c[i] = tot * percent[i];
	}
	totfat += c[0];
	for (i=0; i<5; ++i)
		totc += c[i];
	
	
}


main()
{
	int i, j;

	while (scanf("%s", s[0]))
	{
		totc = totfat = 0;
		if (s[0][0] == '-' ) break;
		for (i=1; i<5; ++i)
			scanf("%s", s[i]);
		count();
		while (1)
		{
			scanf("%s", s[0]);
			if (s[0][0] == '-') break;
			for (i=1; i<5; ++i)
				scanf("%s", s[i]);
			count();
		}
		printf("%.0lf%%\n",totfat/totc*100);

	}


	return 0;
}